/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testas400;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jose Carlos Palma
 */
public class TestAS400 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            ServerSocket server = new ServerSocket(50000);
            System.out.println("Esperando clientes...");
            Socket s = server.accept();
            System.out.println("Cliente aceptado " + s.toString());
            while(true){
                BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
                PrintWriter pw = new PrintWriter(s.getOutputStream(), true);
                
                
                System.out.println("Esperando triggers");
                System.out.println(br.readLine());
                System.out.println("Enviando respuesta");
                s.getOutputStream().write(0);
                s.getOutputStream().flush();
                
            }
            
        } catch (IOException ex) {
            Logger.getLogger(TestAS400.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
}
